
$(function(){
    getShopList();
    function getShopList(){
        $.ajax({
            url : "/shopadmin/getshoplist",
            type : 'get',
            contentType : 'json',
            cache : false,
            success : function(result) {
                handleUser(result.data.user);
                handleList(result.data.shopList);
            }
        });
    }

    function shopStatus(status){
        if(status==0){
            return '审核中';
        }else if(status==-1){
            return '店铺非法';
        }else if(status==1){
            return '审核通过';
        }
    }

    function goShop(status,id){
        if(status==1){
            return '<a href="/shopadmin/shopmanage?shopId='+id+'">进入</a>';
        }else{
            return '';
        }
        window.reload();
    }

    function handleUser(user){
        $('#user-name').text(user.name);
    }

    function handleList(data) {
        var html='';
        data.map(function (item,index) {
            html+='<div class="row row-shop">'
                +'<div class="col-40">'+item.shopName+'</div>'
                +'<div class="col-40">'+shopStatus(item.enableStatus)+'</div>'
                +'<div class="col-20">'+goShop(item.enableStatus,item.shopId)+'</div>'
                +'</div>';
        });
        $('.shop-wrap').html(html);
    }
})